package day04;

import java.util.Scanner;

public class Guessing {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);//创建一个扫描器

        int num = (int) (Math.random() * 1000 + 1);
        System.out.println("答案："+num);//作弊器
        int guess;
        do {
            System.out.println("输入一个0-1000的整数");
            guess = scanner.nextInt();
            if (guess > num) {
                System.out.println("猜大了");
            } else if (guess < num) {
                System.out.println("猜小了");
            } else {
                System.out.println("恭喜你猜对了！");
            }
        } while (guess != num);
        /*生成随机数250，输出提示语，接收用户数据，判断大小，没猜中循环往复*/


        /*
        System.out.println("猜一个0-1000整数");
        int guess = scanner.nextInt();//接收用户数据
        int num = (int) (Math.random() * 1000 + 1);
        while (num != guess) {
            if (guess > num) {
                System.out.println("猜大了");
            } else {
                System.out.println("猜小了");
            }
            guess = scanner.nextInt();
        }
        System.out.println("恭喜你猜对了!");
        // 输入35，判断不等于等于34，再判断大于34，输出猜大了*/
    }
}
